<template>
	<view class="inviteBox">
		<view class="codeBox">
			<view class="box">
				<view class="code">
					<view class="qrimg">
					    <tki-qrcode
					    ref="qrcode"
					   
					    :val="val"
					    :size="size"
					    :unit="unit"
					    
					   
					   
					    :icon="icon"
					    :iconSize="iconsize"
					    :lv="lv" 
					    :onval="onval"
					    :loadMake="loadMake"
					   
					   
					  
					     />
					</view>
					<!-- <image src="../../static/logo2.png"></image> -->
				</view>
				<view class="btn" @click='share'><image src="../../static/icon/yhy-btn.png"></image></view>
			</view>
		</view>
	</view>
</template>

<script>
	
	import QR from "../../components/wxqrcode.js" // 二维码生成器 
	import tkiQrcode from "@/components/tki-qrcode/tki-qrcode.vue"
	export default {
	    components: {tkiQrcode},
	
		
		data(){
				
			return{
				userid:'',
				url:'',
				ifShow: true,
				val: '二维码', // 要生成的二维码值
				size: 390, // 二维码大小
				unit: 'upx', // 单位
				
				icon: '', // 二维码图标
				iconsize: 120, // 二维码图标大小
				lv: 3, // 二维码容错级别 ， 一般不用设置，默认就行
				onval: true, // val值变化时自动重新生成二维码
				loadMake: false, // 组件加载完成后自动生成二维码
				src: '' ,// 二维码生成后的图片地址或base64
				image:'../../static/logo2.png'
			}
		},
		onLoad(option) {
			this.getcode()
			
			
		},
		methods:{
			getcode(){
				let that = this
				this.$http.get('/public/getShareUrl').then(res => {
					if (res.code == 0) {
						that.val = res.data
						console.log(that.val)
						this.$refs.qrcode._makeCode()
					} 
				});
			},
			share(){
				
				let that = this
				console.log(that.val)
				uni.share({
				    provider: "weixin",
				    scene: "WXSceneSession",
				    type: 0,
				    href:that.val,
				    title: '觅术',
				    summary: '二维码分享',
				    imageUrl: that.image,
				    success: function (res) {
						that.videopay.play()
				        console.log("success:" + JSON.stringify(res));
						console.log('分享成功')
						// that.$Request.post(
						// 	that.$api.httpApi.home.shareDiamond
						// ).then(res => {
						// 	if (res.code == 1) {
						// 		console.log('分享成功')
						// 	}
						// })
				    },
				    fail: function (err) {
				        console.log("fail:" + JSON.stringify(err));
				    }
				});
			}	
		}
	}
</script>

<style scoped lang="scss">
	.inviteBox{
		height: 100%;
		width: 100%;
		background: url(../../static/icon/yhy-bg.png) no-repeat center;
		position: fixed;
		background-size:cover;
		.codeBox{
			position: absolute;
			bottom: 150upx;
			width:702upx;
			left: 24upx;
			height:700upx;
			background:rgba(255,242,241,1);
			opacity:0.99;
			border-radius:32upx;
			margin: 0 auto;
			.box{
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;
				.code{
					width: 368upx;
					height: 384upx;
					margin-top: 63upx;
					background: url(../../static/icon/code-bg.png) no-repeat left top;
					background-size: 100% 100%;
					image{
						width: 327upx;
						height: 328upx;
					}
				}
				.btn{
					margin-top: 94upx;
					width: 400upx;
					height: 90upx;
					position: relative;
					image{
						position: absolute;
						width: 400upx;
						height: 90upx;
						left: 0;
						top: 0;
					}
				}
			}
			
		}
	}
</style>
